<template>
    <div>
        <el-space>
            <el-input v-model.trim="userId" placeholder="请输入用户ID" />
            <el-button type="primary" class="iconfont icon-sousuo" @click="seek()">查找</el-button>   
        </el-space>
         <el-table :data="tableData" border style="width: 100%">
            <el-table-column prop="id" label="地址ID"  align="center" />
            <el-table-column prop="userId" label="用户ID" align="center" />
            <el-table-column prop="consignee" label="签收人" align="center" />
            <el-table-column prop="city" label="省份" align="center" />
            <el-table-column prop="province" label="城市" align="center" />
            <el-table-column prop="county" label="区县" align="center" />
            <el-table-column prop="address" label="详情地址" align="center" />      
         </el-table>
             <!-- 分页组件 -->
    <PaginAtion
      class="dins"
      v-bind="paging"
      @handleSizeChange="handleSizeChange"
      @handleCurrentChange="handleCurrentChange"
    >
    </PaginAtion>
    </div>
</template>
<script>
  import PaginAtion from "@/Subassembly/PaginAtion";
import http from '@/http'
export default {
    components: {
      PaginAtion,
    },
    data() {
        return {
            tableData:[],
            userId:"",
            paging: {
          page: 1, //默认第一页
          limit: 10, //显示一行几页
          total: "", //总页
        },
        }
    },
    created(){
        this.address()
    },
    methods:{
        address(){
            let data = {      
                _gp: "admin.address",
                _mt: "list",
                userId:this.userId,
                page: this.paging.page,
                limit: this.paging.limit,         
            }
            http.post(data).then((res)=>{
                console.log(res);
                 if (200 == res.errno) {
                     this.paging.total = res.data.total;
                     this.tableData = res.data.items;
                 }
            })
        },
        seek() {
            if (this.userId == "") {
            return ElMessage.error("查找用户ID不能为空！");
            }
            this.address();
        },
        handleSizeChange(val) {
        this.paging.limit = val;
        this.address();
        },
        handleCurrentChange(val) {
        this.paging.page = val;
        this.address();
        },
    }
}
</script>
<style lang="less" scoped>

</style>